package com.bwhx.eruler.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.bwhx.eruler.bean.Page;
import com.bwhx.eruler.bean.User;
import com.bwhx.eruler.dao.UserDao;

/**
 * @Description:
 */
@Repository
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {
	public UserDaoImpl() {
		this.setNs("com.bwhx.eruler.mapper.UserMapper.");
	}


	public List<User> findByName(String username) {
	
		return getSqlSession().selectList("com.bwhx.eruler.mapper.UserMapper." + "findByName", username);
	}


	@Override
	public List<User> findByMoblie(String mobile) {
		return getSqlSession().selectList("com.bwhx.eruler.mapper.UserMapper." + "findByMoblie", mobile);
	}


	@Override
	public void updateByMobile(User user) {
		this.getSqlSession().update("com.bwhx.eruler.mapper.UserMapper." + "updateByMobile", user);
		
	}


	@Override
	public User find(Integer id) {
		// TODO Auto-generated method stub
		return getSqlSession().selectOne("com.bwhx.eruler.mapper.UserMapper." + "findById", id);
	}


	@Override
	public List<User> list(Page p) {
		
		return getSqlSession().selectList("com.bwhx.eruler.mapper.UserMapper." + "list", p);
	}


	@Override
	public Integer count(User user) {
		
		return getSqlSession().selectOne("com.bwhx.eruler.mapper.UserMapper." + "count", user);
	}


	

	@Override
	public void update(Map<String, Object> mapupdate) {
		
		this.getSqlSession().update("com.bwhx.eruler.mapper.UserMapper." + "updateLoginCount", mapupdate);

	}


	@Override
	public List<User> listRulerUser(Page p) {
		return getSqlSession().selectList("com.bwhx.eruler.mapper.UserMapper." + "listRulerUser", p);
	}


	@Override
	public Integer countRulerUser(Integer rulerId) {
		return getSqlSession().selectOne("com.bwhx.eruler.mapper.UserMapper." + "countRulerUser", rulerId);
	}
	
}
